import Vue from "vue";
import VueRouter from "vue-router";
import Layout from "@/layout";
Vue.use(VueRouter)

// @ 是在webpack配置文件定义的路径简写
export const constantRoutes = [
    {
        path: '/login',
        component: () => import('@/pages/login/index'),
        hidden: true // 过滤掉不需要显示的菜单
    },
    {
        path: '/',
        redirect: '/index',
        component: Layout,
        children: [
            {
                path: '/index',
                name: 'index',
                component: () => import('@/pages/index/index'),
                meta: { title: '主页', icon: 'dashboard', affix: true }
            }
        ]
    },
    {
        path: '/user',
        name: 'user',
        component: Layout,
        meta: { title: '会员管理', icon: 'user' },
        children: [
            {
                path: '/user/list',
                name: 'user_list',
                component: () => import('@/pages/user/list'),
                meta: { title: '会员列表' }
            },
            {
                path: '/user/info',
                name: 'user_info',
                component: () => import('@/pages/user/info'),
                meta: { title: '会员信息' },
                hidden: true
            }
        ]
    },
    {
        path: '/equipment',
        name: 'equipment',
        component: Layout,
        meta: { title: '设备管理', icon: 'component' },
        children: [
            {
                path: '/equipment/list',
                name: 'equipment_list',
                component: () => import('@/pages/equipment/list'),
                meta: { title: '设备列表' }

            },
            {
                path: '/equipment/info',
                name: 'equipment_info',
                component: () => import('@/pages/equipment/info'),
                meta: { title: '设备信息' },
                hidden: true
            }
        ]
    },
    {
        path: '/order',
        name: 'order',
        component: Layout,
        meta: { title: '订单管理', icon: 'shopping' },
        children: [
            {
                path: '/order/list',
                name: 'order_list',
                component: () => import('@/pages/order/list'),
                meta: { title: '订单列表' }

            },
            {
                path: '/order/info',
                name: 'order_info',
                component: () => import('@/pages/order/info'),
                meta: { title: '订单信息' },
                hidden: true
            }
        ]
    },
    {
        path: '/account',
        name: 'account',
        component: Layout,
        meta: { title: '账目管理', icon: 'skill' },
        children: [
            {
                path: '/account/list',
                name: 'account',
                component: () => import('@/pages/account/list'),
                meta: { title: '账目列表' }
            },
            {
                path: '/account/info',
                name: 'account',
                component: () => import('@/pages/account/info'),
                meta: { title: '账目信息' },
                hidden: true
            }
        ]
    },
    {
        path: '/article',
        name: 'article',
        component: Layout,
        meta: { title: '文章管理', icon: 'education' },
        children: [
            {
                path: '/article/list',
                name: 'article',
                component: () => import('@/pages/article/list'),
                meta: { title: '订单列表' }
            },
            {
                path: '/article/info',
                name: 'article',
                component: () => import('@/pages/article/info'),
                meta: { title: '文章信息' },
                hidden: true
            }
        ]
    },
    {
        path: '/setting',
        redirect: '/setting/index',
        component: Layout,
        children: [
            {
                path: '/setting/index',
                name: 'setting_index',
                component: () => import('@/pages/setting/index'),
                meta: { title: '系统设置', icon: 'tab' }
            }
        ]
    }
];

const createRouter = () => new VueRouter({
    // scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher
}

export default router;